package com.ynding.spring.physical.redis.meta.config;

import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;
import org.redisson.config.SingleServerConfig;
import org.redisson.config.TransportMode;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * <p> redisson客户端配置</p>
 *
 * @author ynding
 * @version 2022/4/20
 **/
@Configuration
public class RedissonConfig {

    /**
     * redisson客户端配置
     * @return
     */
    @Bean
    public RedissonClient redissonClient() {
        Config config = new Config();
        config.setTransportMode(TransportMode.NIO);
        SingleServerConfig singleServerConfig = config.useSingleServer();
        singleServerConfig.setAddress("redis://127.0.0.1:6379");
        singleServerConfig.setPassword("123456");
        return Redisson.create(config);
    }
}
